import React, { useState, } from 'react';
import Child from './components/Child';

const CloneElement = () => {

  const [fruit, setFruit] = useState([{fruit: "apple"}]);

  const ChildComponent = <Child fruit={ fruit } />;

  return (
    <div>
      CloneElement
      { ChildComponent }
      {/* { React.cloneElement(ChildComponent, { tag: "我是一个标记", }, (<h2>Hello</h2>)) } */}
      { React.cloneElement(ChildComponent, { fruit: [{fruit: "banana",}], tag: "我是一个标记", }, (<h2>Hello</h2>)) }
    </div>
  );
};

export default CloneElement;
